<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>手机验证-{$tpshop_config['shop_info_store_title']}</title>
    <meta name="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" href="__STATIC__/css/index.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/css/myuser.css" type="text/css">
</head>

<body>
<!--------头部开始-------------->
<include file="Public/header" />
<include file="Public/topnav" />
<!--------头部结束-------------->

<div class="page_pad">
  <div class="page_margin">
    <div class="page_radius page_hidden">
      <div class="page_padin">
        <div class="user_page">
          <div class="user_poi">当前位置：首页 &gt; <span>手机验证</span></div>
          <div class="user_left">
            <include file="User/userleft" />
          </div><!--user_left-->

          <div class="user_right">
            <div class="uright_tit">手机验证：</div>
              <form action="" method="post" onSubmit="return check_form();">
                <div style="width:404px;">
                  <!--步骤二 验证新手机号码-->
                  <div class="ginput_div ginput_div_icon"><i class="icon-shouji"></i><input class="ginput" type="text" name="old_mobile" id="old_mobile" placeholder="{$user_info['mobile']}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" readonly /></div>
                  
                  <div class="ginput_div ginput_div_icon"><i class="icon-shouji"></i><input class="ginput" type="text" name="mobile" id="new_mobile" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" /></div>
                  
                  <div class="ginput_div ginput_div_icon">
                    <div class="fl"><i class="icon-yanzhengma2"></i><input class="ginput" name="code" id="new_code" type="text" placeholder="短信验证码" /></div>
                    <div class="fr"><button type="button" class="reg_send" id="count_down1" onClick="sendCode('new_mobile')">获取短信验证码</button></div>
                    <div class="clear"></div>
                  </div>
                  
                  <div class="ginput_div"><button type="submit" class="login_sub" id="btn_next">提交</button></div>
                </div>
            </form>
          </div><!--user_right-->
          <div class="clear"></div>
        </div><!--user_page-->
      </div><!--page_padin-->
    </div><!--page_radius-->
  </div><!--page_margin-->
</div><!--page_pad-->

<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/pc_common.js"></script>

<!--------footer-开始-------------->
<include file="Public/footer" />
<!--------footer-结束-------------->
<script>
	// 表单提交验证
	function check_form()
	{
        var old_mobile = $('#old_mobile').val();		
        var new_mobile = $('#new_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});// alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(new_mobile)){
            layer.alert('新手机格式错误', {icon: 2});//alert('新手机格式错误');
            return false;
        }	
		
		if($.trim($('#new_code').val()) == '')	
		{
            layer.alert('验证码不能为空', {icon: 2});//alert('验证码不能为空');
            return false;			
		}
		return true;
	} 
    function sendCode(input_id){
        var input = $('#'+input_id).val();
        var old_mobile = $('#old_mobile').val();
        //原邮箱不为空的情况下 验证格式
//        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
//            if(!checkMobile(old_mobile)){
//                layer.alert('原手机格式错误', {icon: 2});//alert('原手机格式错误');
//                return false;
//            }
//        }
        if(!checkMobile(input)){
            layer.alert('手机号码格式错误', {icon: 2});//alert('手机号码格式错误');
            return false;
        }
        if(input_id == 'old_mobile')
            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=1&type=mobile&send="+input;
        if(input_id == 'new_mobile')
//            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=2&type=mobile&send="+input;
            var url = "/index.php?m=Home&c=User&a=send_sms_reg_code&mobile="+input;
        //发送验证码
        $.ajax({
            type : "GET",
            url  : url,
            dataType : 'json',
            error: function(request) {
                layer.alert('服务器繁忙, 请联系管理员!', {icon: 2});//alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(res) {
                if(res.status == 1){
                    layer.alert(res.msg,{icon: 1});
                    counttime = "{$sms_time_out}"; // 手机短信超时时间
				    countdown('#count_down1',counttime);
                }else{
                    layer.alert(res.msg,{icon: 2});//alert('发送失败');
                }
            }
        });
    }

   //倒计时函数
   function countdown(divid,counttime)
	{
		$(divid).attr("disabled","disabled");
		$(divid).addClass("reg_send_off");
		
		counttime--;
        if(counttime<=-1)
        {
			$(divid).removeAttr("disabled");
			$(divid).removeClass("reg_send_off");
            $(divid).html("获取短信验证码");
            return false;
        }

        $(divid).html(counttime+'秒');

        setTimeout("countdown('"+divid+"',"+counttime+")",1000);
	}

</script>

<script>

    countdown("#count_down1","{$stime}");

</script>
</html>